var express = require("express");
var router = express.Router();
var pomelo = require("pomelo");

//通过id查询轮播图
router.get("/getSwiperItemById", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.swiperRemote.getSwiperItemById(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//查询所有轮播图
router.get("/getAllSwiperItems", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.swiperRemote.getAllSwiperItems(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//根据id修改url
router.get("/updateSwiperItemUrl", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.swiperRemote.updateSwiperItemUrl(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//根据id修改Priority
router.get("/updateSwiperItemPriority", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.swiperRemote.updateSwiperItemPriority(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//根据id修改轮播图
router.get("/updateSwiperItem", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.swiperRemote.updateSwiperItem(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//插入轮播图
router.get("/addSwiperItem", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.swiperRemote.addSwiperItem(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

//通过id删除轮播图
router.get("/deleteSwiperItemById", function(req, res) {
    var msg = req.query;
    pomelo.app.rpc.account.swiperRemote.deleteSwiperItemById(null, msg, function(data) {
        res.set({
            'content-type': 'application/json; charset=utf-8'
        }).send(JSON.stringify(data));
    });
});

module.exports = router;